package com.ndp.fb.enums.adgroupstatus;

import lombok.Getter;

/**
 * Created by Sisi on 14-9-20.
 */
@Getter
public enum AdGroupStatus {
    /**
     * ACTIVE
     */
    ACTIVE("ACTIVE", 1),

    /**
     * PAUSED
     */
    PAUSED("PAUSED", 2),

    /**
     * ARCHIVED
     */
    ARCHIVED("ARCHIVED", 3),

    /**
     * CAMPAIGN_PAUSED
     */
    CAMPAIGN_PAUSED("CAMPAIGN_PAUSED", 4),

    /**
     * CAMPAIGN_GROUP_PAUSED
     */
    CAMPAIGN_GROUP_PAUSED("CAMPAIGN_GROUP_PAUSED", 5),

    /**
     * PENDING_REVIEW
     */
    PENDING_REVIEW("PENDING_REVIEW", 6),

    /**
     * DISAPPROVED
     */
    DISAPPROVED("DISAPPROVED", 7),

    /**
     * DELETED
     */
    DELETED("DELETED", 8);

    /**
     * status
     */
    private String status;

    /**
     * code
     */
    private int code;

    /**
     * AdGroupStatus
     *
     * @param status status
     * @param code   code
     */
    private AdGroupStatus(String status, int code) {
        this.status = status;
        this.code = code;
    }

    /**
     * 根据code获取Status
     *
     * @param code code
     * @return Status
     */
    public static AdGroupStatus getStatus(int code) {
        for (AdGroupStatus c : AdGroupStatus.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    /**
     * 根据status获取Status
     *
     * @param status status
     * @return Status
     */
    public static AdGroupStatus getStatus(String status) {
        for (AdGroupStatus c : AdGroupStatus.values()) {
            if (c.status.equals(status)) {
                return c;
            }
        }
        return null;
    }
}
